home *** CD-ROM | disk | FTP | other *** search
- /* Functions for determining features of the operating environment.
-
- Revision History:
-
- 94/01/08 aih
- - added test for temporary memory
-
- 93/12/28 aih
- - split gestalt functions into a separate file
- - removed a few unneeded functions
-
- 93/03/25 AIH
- - Added check for Notification Manager and FindFolder
- - Moved application, INIT, and DA initialization code into
- different libraries
-
- 93/03/12 AIH
- - Added checks for console and profiler
-
- 93/03/10 AIH
- - Added checks for AE manager, aliases, and FSSpec calls
-
- 91/11/15 AIH
- - Changed check for TMON's presence to use Gestalt to determine if TMON
- Professional is installed (as described in the TMON manual).
-
- 91/11/14 AIH
- - Removed checks for system software version 7.0
- - Functions for determining the facilities of QuickDraw return
- correct values (ie, they don't always return the original QD version)
-
- 91/06/13 AIH
- - Functions for determining facilities of QuickDraw always return
- values for the original QuickDraw since I don't have a newer machine
- to test color QuickDraw things on
-
- 91/06/12 AIH
- - Fixed return value from function for getting version of QuickDraw:
- I had forgotten to put the return statement in the function
-
- 91/06/01 AIH
- - Added function to return the reference number of the application
-
- 91/05/27 AIH
- - Added function to determine if FSSpec records are supported by the
- File Manager
-
- 91/05/18 AIH
- - Added function to return the version of QuickDraw
-
- 91/05/17 AIH
- - Enhanced function for getting version of A/UX so it will work
- with pre-2.0 versions of A/UX.
-
- 91/05/13 AIH
- - Added functions to determine if multiple screens are supported
-
- 91/05/07 AIH
- - InitCursor is not called as soon as the managers have been
- initialized since a lot of other initialization still has to
- be done
-
- 91/04/28 AIH
- - Added function for testing for Apple event manager
-
- 91/04/20 AIH
- - Gestalt manager is used where appropriate
- - Upgraded required system version to 6.0.4 so that Gestalt manager can
- always be used
- - Put all global variables used in this library into a single structure
- - Changed some function names to make their purpose clearer
-
- 91/04/18 AIH
- - Added function to determine if notification manager is available
-
- 91/03/25 AIH
- - To speed up use of environs info, SysEnvirons is only called if necessary
-
- 91/03/23 AIH
- - Updated for 7.0 headers
-
- 91/03/11 AIH
- - Got rid of function to determine if a program is executing as an
- application, INIT, or DA
- - Sysenvirons data are stored in a single static variable
-
- 91/01/28 AIH
- - Added function to determine if a program is executing as an application,
- INIT, or DA
-
- 91/01/31 AIH
- - Moved time functions into a time library, and moved stack and heap size
- functions into memory library
-
- 91/01/27 AIH
- - Added functions for getting stack and heap sizes
-
- 91/01/25 AIH
- - MacInitINIT can take a pointer to the QuickDraw globals if InitGraf
- has already been called
- - Removed call to SetApplLimit from MacInitINIT since the neccessary low
- memory globals have not been initialized.
-
- 91/01/21 (or earlier) AIH
- - Adapted MacInit to three versions: for an application, an INIT, and
- a DA. Using these functions, you will always be assured of access to the
- QuickDraw globals.
-
- 91/01/05 Ari Halberstadt (AIH)
- - Inserted this standard header in all files */
-
- #include <GestaltEqu.h>
- #include "GestaltLib.h"
- #include "LowMemLib.h"
- #include "TrapLib.h"
- #include "MacLib.h"
-
- /*----------------------------------------------------------------------------*/
- /* information about the macintosh */
- /*----------------------------------------------------------------------------*/
-
- /* information about the macintosh */
- typedef struct {
- SysEnvRec world; /* environment information */
- short appRefNum; /* application's reference number */
- short appVRefNum; /* application's volume reference number */
- } MacDataType;
-
- /* initialize environment data */
- static void MacDataInit(MacDataType *data)
- {
- Str255 volname;
-
- /* remember application's reference number (this works even when debugging
- under THINK C) and volume reference number */
- data->appRefNum = CurResFile();
- GetVol(volname, &data->appVRefNum);
- (void) SysEnvirons(curSysEnvVers, &data->world);
- }
-
- /* return information about the operating environment */
- static MacDataType *MacData(void)
- {
- static Boolean initialized;
- static MacDataType data;
-
- if (! initialized) {
- MacDataInit(&data);
- initialized = true;
- }
- return(&data);
- }
-
- /*----------------------------------------------------------------------------*/
- /* application and system volume reference numbers */
- /*----------------------------------------------------------------------------*/
-
- /* return the volume reference number of the system folder */
- short MacSysVRef(void)
- {
- /* call SysEnvirons since sysVRefNum can change during execution */
- (void) SysEnvirons(curSysEnvVers, &MacData()->world);
- return(MacData()->world.sysVRefNum);
- }
-
- /* return the volume reference number of the application folder */
- short MacAppVRef(void)
- {
- return(MacData()->appVRefNum);
- }
-
- /* return the reference number of the application file */
- short MacAppRefNum(void)
- {
- return(MacData()->appRefNum);
- }
-
- /* get the name of the application */
- void MacAppName(CStr255 name)
- {
- short ref;
- Handle param;
-
- GetAppParms((StringPtr) name, &ref, ¶m);
- p2cstr((StringPtr) name);
- }
-
- /*----------------------------------------------------------------------------*/
- /* version information */
- /*----------------------------------------------------------------------------*/
-
- short MacVersion(void)
- {
- return(MacData()->world.systemVersion);
- }
-
- short MacVersionAUX(void)
- {
- short result = 0;
-
- if (MacHasGestalt())
- result = LoWord(GestaltResponse(gestaltAUXVersion));
- else if (GetHWCfgFlags() & (1<<9))
- result = 0x0100; /* assume version 1.0 */
- return(result);
- }
-
- short MacVersionQD(void)
- {
- long response = 0;
- short result = gestaltOriginalQD;
-
- if (MacHasGestalt())
- result = LoWord(GestaltResponse(gestaltQuickdrawVersion));
- else if (MacData()->world.hasColorQD)
- result = gestalt8BitQD;
- return(result);
- }
-
- /*----------------------------------------------------------------------------*/
- /* operating capabilities */
- /*----------------------------------------------------------------------------*/
-
- Boolean MacHasGestalt(void)
- {
- return(GestaltAvailable());
- }
-
- Boolean MacHasWNE(void)
- {
- static Boolean initialized;
- static Boolean wne;
-
- if (! initialized) {
- /* do only once for efficiency */
- wne = TrapAvailable(_WaitNextEvent);
- initialized = true;
- }
- return(wne);
- }
-
- Boolean MacHasColor(void)
- {
- /* program_note: needs to be tested on color machines */
- #ifdef COLOR
- return(MacVersionQD() >= gestalt8BitQD);
- #else
- return(false);
- #endif
- }
-
- Boolean MacHasMultipleScreens(void)
- {
- return(MacHasColor());
- }
-
- Boolean MacHasSingleScreen(void)
- {
- return(! MacHasMultipleScreens());
- }
-
- Boolean MacHasTMON(void)
- {
- /* See "TMON Professional Reference", section 9.4.1 "Testing for
- Monitor Presence" (1990, ICOM Simulations, Inc). This only
- works with version 3.0 or later of TMON. */
- return(GestaltResponse('TMON') != 0);
- }
-
- Boolean MacHasMacsBug(void)
- {
- /* program_note: doesn't work with macsbug 6.2.2 */
- return(GestaltBitTst(gestaltOSAttr, gestaltSysDebuggerSupport));
- }
-
- Boolean MacHasDebugger(void)
- {
- return((MacHasMacsBug() || MacHasTMON()));
- }
-
- Boolean MacHasAUX(void)
- {
- return(MacVersionAUX() > 0);
- }
-
- Boolean MacHasAppleEvents(void)
- {
- return(GestaltBitTst(gestaltAppleEventsAttr, gestaltAppleEventsPresent));
- }
-
- Boolean MacHasAliases(void)
- {
- return(GestaltBitTst(gestaltAliasMgrAttr, gestaltAliasMgrPresent));
- }
-
- Boolean MacHasFSSpec(void)
- {
- return(GestaltBitTst(gestaltFSAttr, gestaltHasFSSpecCalls));
- }
-
- Boolean MacHasStandardFile(void)
- {
- return(GestaltBitTst(gestaltStandardFileAttr, gestaltStandardFile58));
- }
-
- Boolean MacHasHelpManager(void)
- {
- return(GestaltBitTst(gestaltHelpMgrAttr, gestaltHelpMgrPresent));
- }
-
- Boolean MacHasNotificationMgr(void)
- {
- return(GestaltBitTst(gestaltNotificationMgrAttr, gestaltNotificationPresent));
- }
-
- Boolean MacHasFindFolder(void)
- {
- return(GestaltBitTst(gestaltFindFolderAttr, gestaltFindFolderPresent));
- }
-
- Boolean MacHasTempMem(void)
- {
- long response;
-
- response = GestaltResponse(gestaltOSAttr);
- return((response & (1 << gestaltTempMemSupport)) &&
- (response & (1 << gestaltRealTempMemory)) &&
- (response & (1 << gestaltTempMemTracked)));
- }
-
- /* true if there's a console window we can use printf with */
- Boolean MacHasConsole(void)
- {
- return(true);
- }
-
- /* true if we're profiling the code */
- Boolean MacHasProfiler(void)
- {
- return(PROFILE);
- }
-
-